|
Server : Apache System : Linux server.mata-lashes.com 3.10.0-1160.90.1.el7.x86_64 #1 SMP Thu May 4 15:21:22 UTC 2023 x86_64 User : matalashes ( 1004) PHP Version : 8.1.29 Disable Function : NONE Directory : /home/matalashes/www/kite.mata-lashes.com/vendor/rector/rector/vendor/nette/neon/src/Neon/ |
Upload File : |
<?php
/**
* This file is part of the Nette Framework (https://nette.org)
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
*/
declare (strict_types=1);
namespace RectorPrefix20211231\Nette\Neon;
/**
* Simple parser & generator for Nette Object Notation.
* @see https://ne-on.org
*/
final class Neon
{
public const BLOCK = \RectorPrefix20211231\Nette\Neon\Encoder::BLOCK;
public const CHAIN = '!!chain';
/**
* Returns value converted to NEON.
*/
public static function encode($value, bool $blockMode = \false, string $indentation = "\t") : string
{
$encoder = new \RectorPrefix20211231\Nette\Neon\Encoder();
$encoder->blockMode = $blockMode;
$encoder->indentation = $indentation;
return $encoder->encode($value);
}
/**
* Converts given NEON to PHP value.
* @return mixed
*/
public static function decode(string $input)
{
$decoder = new \RectorPrefix20211231\Nette\Neon\Decoder();
return $decoder->decode($input);
}
/**
* Converts given NEON file to PHP value.
* @return mixed
*/
public static function decodeFile(string $file)
{
if (!\is_file($file)) {
throw new \RectorPrefix20211231\Nette\Neon\Exception("File '{$file}' does not exist.");
}
$input = \file_get_contents($file);
if (\substr($input, 0, 3) === "") {
// BOM
$input = \substr($input, 3);
}
return self::decode($input);
}
}